{% extends "../layouts/app.html" %}

{% block title %}登录{% endblock %}

{% block content %}
<div class="container">
  <div class="row justify-content-center">
    <div class="col-md-8">
      <div class="card">
        <div class="card-header">登录</div>

        <div class="card-body">
          <form method="POST" action="{% route 'login' %}">
            {{ csrfInput | safe }}

            <div class="form-group row">
              <label for="email" class="col-md-4 col-form-label text-md-right">E-mail</label>

              <div class="col-md-6">
                <input id="email" type="email" class="form-control {% if validatorMessageMap.email %} is-invalid {% endif %}"
                  name="email" value="{{ oldValue.email }}" required autofocus>

                {% if validatorMessageMap.email %}
                  <span class="invalid-feedback" role="alert">
                    <strong>{{ validatorMessageMap.email.0 }}</strong>
                  </span>
                {% endif %}
              </div>
            </div>

            <div class="form-group row">
              <label for="password" class="col-md-4 col-form-label text-md-right">密码</label>

              <div class="col-md-6">
                <input id="password" type="password" class="form-control {% if validatorMessageMap.password %} is-invalid {% endif %}"
                  name="password" required>

                 {% if validatorMessageMap.password %}
                  <span class="invalid-feedback" role="alert">
                    <strong>{{ validatorMessageMap.password.0 }}</strong>
                  </span>
                {% endif %}
              </div>
            </div>

            <div class="form-group row">
              <div class="col-md-6 offset-md-4">
                <div class="form-check">
                  <input class="form-check-input" type="checkbox" name="remember" id="remember"
                    {% if oldValue.remember %} checked {% else %} '' {% endif %}>

                  <label class="form-check-label" for="remember">
                    记住我
                  </label>
                </div>
              </div>
            </div>

            <div class="form-group row">
              <div class="col-md-8 offset-md-4">
                <button type="submit" class="btn btn-primary">
                  登录
                </button>

                <a class="btn btn-link" href="{% route 'password.request' %}">
                  忘记密码
                </a>
              </div>
            </div>

            <div class="form-group row offset-md-4" margin-top>默认账号: 1@test.com/123456</div>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>
{% endblock %}
